package com.film.admincontroller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.Director;
import com.film.service.impl.DirectorServiceImpl;


@WebServlet("/selectDirectorById")
public class selectDirectorById extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String selectIf = request.getParameter("selectIf");
		System.out.println(selectIf);
		if("updateDirector".equals(selectIf)){
			
			Integer dirId= Integer.parseInt(request.getParameter("dirId"));
		 	DirectorServiceImpl ds = new DirectorServiceImpl();
			Director director=ds.selectDirectorById(dirId);
			HttpSession session= request.getSession();
			session.setAttribute("director",director);
			response.sendRedirect("/film/admin_jsp/director.jsp");
		}
		if("directorDetail".equals(selectIf)){
			Integer dirId= Integer.parseInt(request.getParameter("dirId"));
		 	DirectorServiceImpl ds = new DirectorServiceImpl();
			Director director=ds.selectDirectorById(dirId);
			HttpSession session= request.getSession();
			session.setAttribute("director",director);
			response.sendRedirect("/film/admin_jsp/director.jsp");
		}
	}

	
	
}
